define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree','echarts','echarts-theme'], function ($, undefined, Backend, Table, Form,undefined,Echarts) {

    $('#c-type').change(function(){
        if($('#c-type').val()==1||$('#c-type').val()==3){
           // $('.house-area').show();
            $('.house-good').hide();
            $("#c-name").removeAttr("readonly","readonly")
        }else{
            $('.house-good').show();
            $("#c-name").attr("readonly",true)
           // $('.house-area').hide();
        }
      
    })

    $('#excel-btn').click(function(){
        Fast.api.open('information/shelves/excel','出入库导入');
    })

    //自动生成货架名字
     $("#c-layers_number,#c-column_number,#c-row_number").change(function(){
          let layers_number =$("#c-layers_number").val();
          let column_number =$("#c-column_number").val();
          let row_number =$("#c-row_number").val();
          if(layers_number.length==1) layers_number="0"+layers_number;
          if(column_number.length==1) column_number="0"+column_number;
          if(row_number.length==1) row_number="0"+row_number;
          $("#c-name").val("第"+row_number+"行 "+"第"+column_number+"列 "+"第"+layers_number+"层");
     })

    $(function(){
        if($('#c-type').val()==1||$('#c-type').val()==3){
           // $('.house-area').show();
            $('.house-good').hide();
            $("#c-name").removeAttr("readonly","readonly")
        }else if($('#c-type').val()==2){
            $('.house-good').show();
            $("#c-name").attr("readonly",true)
           // $('.house-area').hide();
        }
    });

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'information/shelves/index' + location.search,
                    add_url: 'information/shelves/add',
                    edit_url: 'information/shelves/edit',
                    del_url: 'information/shelves/del',
                    multi_url: 'information/shelves/multi',
                    import_url: 'information/shelves/import',
                    table: 'shelves',
                }
            });
            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'warehouse_id', title: __('Warehouse_id'),visible:false,searchList:$.getJSON('ajax/getWarehouseDataSearchList'),defaultValue:'2'},
                        {field: 'warehouse_name', title: __('Warehouse_name'),operate:false,searchList:warehouse_arr,formatter: Table.api.formatter.normal},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal,width:80},
                        {field: 'number', title: __('Number'), operate: 'LIKE',width:100},
                        {field: 'name', title: "位置描述", operate: 'LIKE',width:150},
                      //  {field: 'switch', title: __('Switch'), searchList: {"0":__('Switch 0'),'1':__('Switch 1')}, table: table, formatter: Table.api.formatter.toggle},
                        {field: 'led_position', title: __('LED位置'), operate: 'LIKE'},
                        {field: 'ifempty', title: __('Ifempty'), searchList: {"0":__('Empty 0'),"1":__('Empty 1')}, formatter: Table.api.formatter.normal},
                        {field: 'row_number', title: __('Row_number'),visible:false},
                        {field: 'column_number', title: __('Column_number'),visible:false},
                        {field: 'layers_number', title: __('Layers_number'),visible:false},
                        {field: 'inv_class_name', title: __('Inv_class') ,operate: 'LIKE'},  
                        {field: 'ifmix', title: __('Ifmix'), operate: 'LIKE',searchList: {"1":__('Yes'),"2":__('No')}, formatter: Table.api.formatter.normal},
                        {field: 'wh_type', title: __('Wh_type'), operate: 'LIKE',searchList: {"1":__('标准仓'),"2":__('代管仓')}, formatter: Table.api.formatter.normal},
                        //{field: 'ifbatch', title: __('Ifbatch'), operate: 'LIKE',searchList: {"1":__('Yes'),"2":__('No')}, formatter: Table.api.formatter.normal},
                       // {field: 'size', title: __('Size'), operate: 'LIKE'},
                        //{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                       // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,width:80}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            $('#print-btn-ww').click(function(){
                let allids =  Controller.api.selectedid(table);
                if(allids.length==0) return Toastr.error("请先选择货架/库区");   
                Fast.api.open('information/warehouse/print?warehouse_id='+allids,'打印信息');
            })

            $("[name='warehouse_id']").on('change',function(){
                Controller.api.tree();
            })
        },
        indexpad2: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'information/shelves/indexpad' + location.search,
                    multi_url: 'information/shelves/multi',
                    table: 'shelves',
                }
            });
            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                clickToSelect:true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'warehouse_id', title: __('Warehouse_id'),visible:false,searchList:$.getJSON('ajax/getWarehouseDataSearchList'),defaultValue:'2'},
                        {field: 'warehouse_name', title: __('Warehouse_name'),operate:false,searchList:warehouse_arr,formatter: Table.api.formatter.normal,width:150},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal,width:120},
                        {field: 'number', title: __('Number'), operate: 'LIKE',width:200},
                        {field: 'name', title: "位置描述", operate: 'LIKE',width:200},
                        {field: 'ifempty', title: __('Ifempty'), searchList: {"0":__('Empty 0'),"1":__('Empty 1')}, formatter: Table.api.formatter.normal,sortable:true},
                        {field: 'row_number', title: __('Row_number'),visible:false},
                        {field: 'column_number', title: __('Column_number'),visible:false},
                        {field: 'layers_number', title: __('Layers_number'),visible:false},
                        //{field: 'inv_class_name', title: __('Inv_class') ,operate: 'LIKE'},  
                        //{field: 'ifmix', title: __('Ifmix'), operate: 'LIKE',searchList: {"1":__('Yes'),"2":__('No')}, formatter: Table.api.formatter.normal},
                        {field: 'wh_type', title: __('Wh_type'), operate: 'LIKE',searchList: {"1":__('标准仓'),"2":__('代管仓')}, formatter: Table.api.formatter.normal},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,width:80}
                    ]
                ],
                rowStyle: function (row, index) {
                    var style = {}
                    if(row.ifempty){
                        style = {css:{'background':'#18bc9c3b'}};
                    }else{
                        style = {css:{'background':'#ebbcc3'}};
                    }
                    return style;
                },
            });

            //自定义Tab筛选条件
            $('.panel-heading .nav-custom-condition a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
                var value = $(this).data("value");
                var options = table.bootstrapTable('getOptions');
                var queryParams = options.queryParams;
                options.pageNumber = 1;
                options.queryParams = function (params) {
                    //这一行必须要存在,否则在点击下一页时会丢失搜索栏数据
                    params = queryParams(params);
                    //如果希望追加搜索条件,可使用
                    var filter = params.filter ? JSON.parse(params.filter) : {};
                    var op = params.op ? JSON.parse(params.op) : {};
                    if (value) {
                        //这里可以自定义多个筛选条件 1=库区,2=货架 3=托盘
                    	filter.type = value
                        $("[name='type']").val(value)
                        if(value==5){
                            $("[name='type']").val('')
                        }
                    } else {
                        //选全部时要移除相应的条件
                        //delete filter.order_list;
                        //delete op.order_list;
                    }

                    params.filter = JSON.stringify(filter);
                    params.op = JSON.stringify(op);

                    //如果希望忽略搜索栏搜索条件,可使用
                    //params.filter = JSON.stringify(value?{admin_id: value}:{});
                    //params.op = JSON.stringify(value?{admin_id: '='}:{});
                    return params;
                };

                table.trigger("uncheckbox");
                table.bootstrapTable('refresh', {pageNumber: 1});
                return false;
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            //定时器,每20秒刷新一次
            var timer = setInterval(function() {
            	//$("a.btn-refresh").trigger("click");
                Controller.shelvesChart({type:2,row_number:1},'shelves-chart-1');
                Controller.shelvesChart({type:2,row_number:2},'shelves-chart-2');
                Controller.shelvesChart({type:1},'shelves-chart-3');
                Controller.shelvesChart({type:3},'shelves-chart-4');
            }, 6*1000);
            
            $("#btn-stop-refresh").on('click',function(){
            	if($("#btn-stop-refresh").html()=='停止刷新'){
            		$("#btn-stop-refresh").html('开启刷新')
            		clearInterval(timer)
            	}else{
            		$("#btn-stop-refresh").html('停止刷新')
            	    timer = setInterval(function() {
                     	//$("a.btn-refresh").trigger("click");
                    }, 20*1000);
            	}
            })

            $('#print-btn-ww').click(function(){
                let allids =  Controller.api.selectedid(table);
                if(allids.length==0) return Toastr.error("请先选择货架/库区");   
                Fast.api.open('information/warehouse/print?warehouse_id='+allids,'打印信息');
            })
        },
        indexpad: function () {
            Controller.shelvesChart({type:2,row_number:1},'shelves-chart-1');
            Controller.shelvesChart({type:2,row_number:2},'shelves-chart-2');
            Controller.shelvesChart({type:1},'shelves-chart-3');
            Controller.shelvesChart({type:3},'shelves-chart-4');
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'information/shelves/recyclebin' + location.search,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), align: 'left'},
                        {
                            field: 'deletetime',
                            title: __('Deletetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'operate',
                            width: '140px',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'Restore',
                                    text: __('Restore'),
                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                    icon: 'fa fa-rotate-left',
                                    url: 'information/shelves/restore',
                                    refresh: true
                                },
                                {
                                    name: 'Destroy',
                                    text: __('Destroy'),
                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                    icon: 'fa fa-times',
                                    url: 'information/shelves/destroy',
                                    refresh: true
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        choose:function(){
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var chooseTable = $('#chooseTable')
            var single = true
            if(Fast.api.query("single")==0){
            	single = false
            }
            
            chooseTable.bootstrapTable({
                url: "information/shelves/choose" + location.search,
                pk: 'id',
                search:false,
                pageList:[15,25,50],
                singleSelect:single,
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        //{field: 'id', title: __('Id')},
                       {field: 'warehouse_id', title: __('Warehouse_id'),visible:false,searchList:$.getJSON('ajax/getWarehouseDataSearchList')},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'number', title: __('Number'), operate: 'LIKE'},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                      //  {field: 'switch', title: __('Switch'), searchList: {"0":__('Switch 0'),'1':__('Switch 1')}, table: table, formatter: Table.api.formatter.toggle},
                       // {field: 'source', title: __('Source'), searchList: {"1":__('Source 1')," 2":__('Source  2')}, formatter: Table.api.formatter.normal},
                       {field: 'column_number', title: __('Column_number'),visible:false},
                       {field: 'layers_number', title: __('Layers_number'),visible:false},
                       {field: 'row_number', title: __('Row_number'),visible:false}
                       
                        //{field: 'max_number', title: __('Max_number'), operate: 'LIKE'},
                       // {field: 'max_weight', title: __('Max_weight'), operate: 'LIKE'},
                       // {field: 'max_volume', title: __('Max_volume'), operate: 'LIKE'},
                       // {field: 'size', title: __('Size'), operate: 'LIKE'},
                       //  {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                       // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                       // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            

            //点击弹窗的-确认按钮
            $('#choose_id').click(function(){
            	if(single){
            		let id =  Controller.api.selectedids(chooseTable);
                    Fast.api.close(id);
            	}else{
            		var selections = chooseTable.bootstrapTable('getSelections');
                    Fast.api.close(selections);
            	}
            })
            
            // 为表格绑定事件
            Table.api.bindevent(chooseTable);
            $("[name='warehouse_id']").on('change',function(){
                Controller.api.tree();
            })
        },
        chooseinv:function(){
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var chooseTable = $('#chooseTable')
            var single = true
            if(Fast.api.query("single")==0){
                single = false
            }
            
            chooseTable.bootstrapTable({
                url: "information/inventory/index" + location.search,
                pk: 'id',
                search:false,
                pageList:[15,25,50],
                singleSelect:single,
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        //{field: 'id', title: __('Id')},
                       {field: 'warehouse_id', title: __('Warehouse_id'),visible:false,searchList:$.getJSON('ajax/getWarehouseDataSearchList')},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
                        {field: 'number', title: __('Number'), operate: 'LIKE'},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                      //  {field: 'switch', title: __('Switch'), searchList: {"0":__('Switch 0'),'1':__('Switch 1')}, table: table, formatter: Table.api.formatter.toggle},
                       // {field: 'source', title: __('Source'), searchList: {"1":__('Source 1')," 2":__('Source  2')}, formatter: Table.api.formatter.normal},
                       {field: 'column_number', title: __('Column_number'),visible:false},
                       {field: 'layers_number', title: __('Layers_number'),visible:false},
                       {field: 'row_number', title: __('Row_number'),visible:false}
                       
                        //{field: 'max_number', title: __('Max_number'), operate: 'LIKE'},
                       // {field: 'max_weight', title: __('Max_weight'), operate: 'LIKE'},
                       // {field: 'max_volume', title: __('Max_volume'), operate: 'LIKE'},
                       // {field: 'size', title: __('Size'), operate: 'LIKE'},
                       //  {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                       // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                       // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
        },
        excel:function(){
            Controller.api.bindevent();
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
        	$(document).on("change", "#c-inv_class1_id", function(){
        		$('#c-inv_class2_id').selectPageClear();
        		$('#c-inv_class3_id').selectPageClear();
        	});

            $('#choose-inventory').click(function(){
                top.Fast.api.open('information/inventory/choose?flag=tp','选择存放物料',{offset: 'r',callback:function(value){
                    // let old_inv_ids_arr = [];
                    // if($("#c-inventory_id").val()){
                    //     old_inv_ids_arr = $("#c-inventory_id").val().split(',')
                    // }
                    
                    // $.each(value,function(i,n){
                    //     if($.inArray(n,old_inv_ids_arr)==-1) {
                    //         old_inv_ids_arr.push(n);
                    //     }
                    // });

                    // if(old_inv_ids_arr.length){
                    //     $("#c-inventory_id,#c-inventory_name").val(old_inv_ids_arr.join(','));
                    // }
                    
                    if(!value.length){
                        $("#c-inventory_id,#c-inventory_name").val('');
                        $('#c-inventory_name').selectPageClear();
                    }else{
                        $("#c-inventory_id,#c-inventory_name").val(value.join(','));
                    }
                    
                     $("#c-inventory_name").selectPageRefresh();
                }});
             })

            Controller.api.bindevent();
        },
        api: {

             //获取选中的行
             selectedid: function (table, current) {
                var options = table.bootstrapTable('getOptions');
                //如果有设置翻页记忆模式
                if (!current && options.maintainSelected) {
                    return options.selectedIds;
                }
                return $.map(table.bootstrapTable('getSelections'), function (row) {
                    return row[options.pk];
                });
            },


            selectedids: function (table, current) {
                var option = table.bootstrapTable('getOptions');
                return  option.selectedData[0];
                //如果有设置翻页记忆模式
                // if (!current && options.maintainSelected) {
                //     return options.selectedIds;
                // }
                // return $.map(table.bootstrapTable('getSelections'), function (row) {
                //     return options.pk;
                // });
            },
             
            bindevent: function () {
                $('form[role=form]').data("validator-options", {
                    ignore: ':hidden'
                });
                Form.api.bindevent($("form[role=form]"));
            },
            rendertree: function (content) {
                $("#treeview")
                    .on('redraw.jstree', function (e) {
                        $(".layer-footer").attr("domrefresh", Math.random());
                    }).on('changed.jstree', function (e, data) {
                    let node_id = data.node.id;
                    let node_parent = data.node.parent;
                    let node_parents = data.node.parents;
                    let parents_length = node_parents.length;
                    let text = data.node.text;
                    let row_number = '';
                    let column_number = '';
                    let layers_number = '';
                    
                    //货架
                    if (node_id == '999999' && node_parent == '#') {
                        $("[name='type']").val(2)
                        $("[name='row_number']").val('');
                        $("[name='column_number']").val('');
                        $("[name='layers_number']").val('');
                        $("[name='name']").val('');
                    }
                    //库区
                    if (node_id == '999998' && node_parent == '#') {
                        $("[name='type']").val(1)
                        $("[name='row_number']").val('');
                        $("[name='column_number']").val('');
                        $("[name='layers_number']").val('');
                        $("[name='name']").val('');
                    }
                    //托盘
                    if (node_id == '999997' && node_parent == '#') {
                        $("[name='type']").val(3)
                        $("[name='row_number']").val('');
                        $("[name='column_number']").val('');
                        $("[name='layers_number']").val('');
                        $("[name='name']").val('');
                    }
                    if (node_parents.includes('999997') && node_id != 999997) {
                        $("[name='type']").val(3)
                        var text_arr = text.split(' ');
                        $("[name='name']").val(text_arr[1]);
                    }
                    if (node_parents.includes('999998') && node_id != 999998) {
                        $("[name='type']").val(1)
                        var text_arr = text.split(' ');
                        $("[name='name']").val(text_arr[1]);
                    }
                    if (node_parents.includes('999999') && node_id != 999999) {
                        $("[name='type']").val(2)
                        $("[name='name']").val('');
                        if (parents_length == 2) {
                            row_number = node_id;
                        }
                        if (parents_length == 3) {
                            row_number = node_parents[0];
                            column_number = node_id.replace(row_number, '');
                        }
                        if (parents_length == 4) {
                            row_number = node_parents[1];
                            column_number = node_parents[0].replace(row_number, '');
                            layers_number = node_id.replace(node_parents[0], '');
                        }
                    }
                    $("[name='row_number']").val(row_number);
                    $("[name='column_number']").val(column_number);
                    $("[name='layers_number']").val(layers_number);
                    $("[type='submit']").trigger('click')
                }).jstree({
                    "plugins": [ "themes",'types'],
                    "core": {
                        'check_callback': true,
                        "data": content
                    }
                });
            },
            tree:function (){
                let warehouse_id =  $("[name='warehouse_id']").val();
                $.ajax({
                    url: "information/Shelves/getTreeData",
                    type: 'post',
                    dataType: 'json',
                    data: {warehouse_id: warehouse_id},
                    success: function (ret) {
                        if (ret.hasOwnProperty("code")) {
                            var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : "";
                            if (ret.code === 1) {
                                //销毁已有的节点树
                                $("#treeview").jstree("destroy");
                                Controller.api.rendertree(data);
                            } else {
                                Backend.api.toastr.error(ret.msg);
                            }
                        }
                    }, error: function (e) {
                        Backend.api.toastr.error(e.message);
                    }
                })
            }
        },
        shelvesChart:function(condition = {},id = 'shelves-chart-1'){
        	//var loadindex = layer.load(0);
            $.ajax({
                url:"information/shelves/getEchartData",
                type:"POST",
                data:condition,
                dataType:"json",
                success:function (res){
	        	//货架，热点图
	            var shelvesChart = Echarts.init(document.getElementById(id), 'walden');
	            //横坐标name
                var xAxis = res[2];//['第1列', '第2列'];
                //纵坐标name
                var yAxis = res[3];//['第1层', '第2层', '第3层', '第4层'];
                var data = [];
                for (var i = 0; i < xAxis.length; i++) {
                    let arr = [];
                    for (var j = 0; j < yAxis.length; j++) {
                        let value = parseInt(Math.random() * 2);
                        //需求: 指定目标和安全时间固定颜色，剩下的超时时间数量根据条件判断来决定颜色
                        // 值，下标
                        let itemStyle = setColors(value, j);
                        let obj = {};
                        obj.itemStyle = itemStyle;
                        //obj.value = [i, j, value];
                        obj.value = [i,j,res[0][i+1][j+1]] 
                        obj.name = res[1][i+1][j+1]
                        data.push(obj)
                    }
                }

                    var option = {
                        animation: true,
                        title: {
                            text: res[4],
                            left: 'center',
                            textStyle: {
                                color: "#000"
                            },
                            top: '2%'
                        },
                        tooltip: {
                            formatter : function(params){  
                                //console.log(params);//打印params
                                //params.value = '';
                                let str = params.marker+params.seriesId+params.name;
                                str+='<br>'+params.marker+'<b>点击查看库存明细</b>';
                                return  str;
                            },
                            position: 'top',
                            backgroundColor: 'rgba(42, 47, 53, 0.9)',
                            borderColor: '#000000',
                            textStyle: {
                                color: "#fff"
                            },
                            axisPointer: {
                                lineStyle: {
                                    color: '#fff'
                                }
                            }
                        },
                        grid: {
                            left: '2%',
                            right: '6%',
                            bottom: '2%',
                            top: '15%',
                            containLabel: true
                        },
                        xAxis: [{
                            type: 'category',
                            data: xAxis,
                            // splitArea: {
                            //     show: true
                            // },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: "#fff", //同背景色
                                    width: 5,
                                },
                            },
                            axisLabel: {
                                show: condition.type==2?true:false,//顶部文字
                                textStyle: {
                                    color: '#000',
                                },
                                interval: 0,
                                rotate: 10
                            },
                        }],
                        yAxis: {
                            type: 'category',
                            data: yAxis,
                            // splitArea: {
                            //     show: true
                            // },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: "#fff", //同背景色
                                    width: 5,
                                },
                            },
                            axisLabel: {
                                show: true,
                                textStyle: {
                                    color: condition.type==2?'#000':'#FFF',
                                },
                                interval: 0,
                                rotate: 10
                            },
                        },
                        visualMap: {
                            min: 0,
                            max: 1,
                            show:false,
                            calculable: true,
                            orient: 'vertical',
                            left: 'right',
                            top: 'center',
                            textStyle: {
                                color: "#fff"
                            },
                            // bottom: '15%',
                            //自定义热力图颜色
                            inRange: {
                                color: ['#a1e89e', '#ea8f8f']
                            },
                        },
                        series: [{
                            name: '编码:',
                            type: 'heatmap',
                            data: data,
                            
                            label: {
                                show: true,
                                textStyle: {
                                    color: "#000"
                                },
                                formatter : function(params){  
                                    console.log(params);//打印params
                                    //params.value = '';
                                    return  params.name;
                                },
                            },
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 20,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            },
                            zlevel:-1
                        }]
                    };
                    shelvesChart.clear();
                    // 使用刚指定的配置项和数据显示图表。
                    shelvesChart.setOption(option);

                    //热力图点击事件
                    shelvesChart.off('click');
                    shelvesChart.on('click', function(e) {
                        //console.log(e.data.name)
                        //var loadindex0 = layer.load(0);
                        Fast.config.openArea = ['70%','70%'];
                        Fast.api.open('inventory/wmskc/index?shelves_number='+e.data.name,'查看库存明细');
                        //layer.close(loadindex0);
                    });
                }
            })
        	Controller.api.bindevent();
        }
    };
    return Controller;
});

//这里需要手动为Form绑定上元素事件
$("#c-inv_class2_id").data("params", function (obj) {
    //obj为SelectPage对象
    return {custom: {pid: ['IN',$("#c-inv_class1_id").val()]}};
});
$("#c-inv_class3_id").data("params", function (obj) {
    //obj为SelectPage对象
    return {custom: {pid: ['IN',$("#c-inv_class2_id").val()]}};
});

// 筛选颜色
function setColors(val, index) {
    let obj = {};
    let color = null;
    if (val == 0) {
        color = "#a1e89e";
    } else if (val == 1) {
        color = "#ea8f8f";
    }

    if (color != null) {
        obj = {
            normal: {
                color: color,
            }
        }
    }
    return obj;
}